#include "error.h"

#include <stdio.h>
#include <stdarg.h>

#define WIN32_LEAN_AND_MEAN
#include <windows.h>

enum DebugLevel
{
	DebugLevel_Message,
	DebugLevel_Warning,
	DebugLevel_Error
};

static void print(enum DebugLevel level, const char* msg)
{
	char str[2000];
	const char* typeStr = NULL;

	if(level == DebugLevel_Message)
		typeStr = "INFO";
	else if(level == DebugLevel_Warning)
		typeStr = "WARNING";
	else
		typeStr = "ERROR";

	sprintf(str, "%s: mem: %s\n", typeStr, msg);

	OutputDebugStringA(str);
}

void error(const char* fmt, ...)
{
	// format variable arguments
	char msg[1024];
	va_list marker;
	va_start(marker, fmt);
	vsprintf(msg, fmt, marker);
	va_end(marker);

	print(DebugLevel_Error, msg);
}

void message(const char* fmt, ...)
{
	// format variable arguments
	char msg[1024];
	va_list marker;
	va_start(marker, fmt);
	vsprintf(msg, fmt, marker);
	va_end(marker);

	print(DebugLevel_Message, msg);
}